package com.example.chenduoyun.profect.activity;
/**
 * @author cdy
 */

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

import com.example.chenduoyun.profect.R;
import com.example.chenduoyun.profect.ui.ToggleView;

public class MainActivity extends AppCompatActivity {
    private ToggleView toggleView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        toggleView = findViewById(R.id.toggle_view);
        toggleView.setOnSwitchStateUpdateListener(new ToggleView.OnSwithchStateUpdateListener(){
            @Override
            public void onStateUpdate(boolean state) {
                if(state) {
                    Toast.makeText(getApplicationContext(), "开关打开了", Toast.LENGTH_SHORT).show();
                }else{
                    Toast.makeText(getApplicationContext(), "开关关掉了", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
    }
}
